package com.dongjiantong.biz.serviceImpl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongjiantong.biz.mapper.StablesMapper;
import com.dongjiantong.biz.model.Stables;
import com.dongjiantong.biz.service.StablesService;
import com.dongjiantong.mybatis.ServiceMybatis;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by ThinkPad on 2017/11/17.
 */
@Slf4j
@Service(version = "1.0.0")
public class StablesServiceImpl extends ServiceMybatis<Stables> implements StablesService {

    @Resource
    private StablesMapper stablesMapper;

    /**
     * todo 创建多个存栏
     *
     * @param stables
     * @return
     */
    @Override
    public Boolean createStablesSome(List<Stables> stables) {
        try {
            int a = stablesMapper.insertList(stables);
            if (a != stables.size()) {
                return false;
            }
            return true;
        } catch (Exception e) {
            log.error(e.getMessage());

            return false;
        }

    }

    /**
     * todo 更新多个存栏
     *
     * @param stables
     * @return
     */
    public Boolean updateStablesSome(List<Stables> stables) {
        try {
            int result=0;
            for (Stables stables1:stables){
            result=    stablesMapper.updateByPrimaryKeySelective(stables1);
            }
            if (result != stables.size()) {
                return false;
            }
            return true;
        } catch (Exception e) {
            log.error(e.getMessage());

            return false;
        }


    }

    @Override
    public void updateSC(Stables stables) {
        stablesMapper.updateSC(stables);
    }
}
